package com.aaa.service.impl;

import com.aaa.entity.TabUserRole;
import com.aaa.mapper.TabUserRoleMapper;
import com.aaa.service.ITabUserRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 于永利
 * @since 2024-08-03
 */
@Service
public class TabUserRoleServiceImpl extends ServiceImpl<TabUserRoleMapper, TabUserRole> implements ITabUserRoleService {

    @Autowired
    private TabUserRoleMapper tabUserRoleMapper;
    @Override
    public void saveUserRoles(List<Integer> permissions, Integer id) {
        // 根据用户的id 删除之前的角色的信息
        Map<String,Object> map=new HashMap<>();
        map.put("uid",id);
        tabUserRoleMapper.deleteByMap(map);
        tabUserRoleMapper.addUserRole(permissions,id);
    }
}
